home *** CD-ROM | disk | FTP | other *** search
/ Sound Fx / Sound Fx.iso / Software / UNZIPED / MPW181-5 / _SETUP.1 / mciplay.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-20  |  1.5 KB  |  65 lines

  1. /* mciplay.cpp
  2.  
  3.    A simple function to send the playback time back to the main window and
  4.    handle seeks. This operates using the MCI command strings, and assumes
  5.    that a sound file aliased "sounder" is already loaded. Written by
  6.    Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu).
  7.  
  8.    Last modified : 01/28/97 */
  9.  
  10. #define STRICT
  11. #include <windows.h>
  12.  
  13. #include "str_lib.h"
  14. #include "args.h"
  15. #include "mp2win.h"
  16.  
  17. DWORD mciplay (MCI_Args *args)
  18. {
  19.     char mci_buffer[1024];
  20.     char mci_command[256];
  21.     char ms_buffer[32];
  22.  
  23.    HANDLE mutex = args->mutex;
  24.  
  25.     while(TRUE) {
  26.  
  27.        WaitForSingleObject(mutex, INFINITE);
  28.        if (args->stop) {
  29.          args->done = TRUE;
  30.          ReleaseMutex(mutex);
  31.           return(0);
  32.       }
  33.  
  34.         // Handle seeks
  35.  
  36.         if (args->position_change) {
  37.  
  38.             mciSendString("stop sounder", mci_buffer, 1024, NULL);
  39.             lstrcpy(mci_command, "seek sounder to ");
  40.             lstrcat(mci_command, my_itoa(args->desired_position,
  41.                                       ms_buffer, 10));
  42.             lstrcat(mci_command, " wait");
  43.             mciSendString(mci_command, mci_buffer, 1024, NULL);
  44.  
  45.             if (args->playing)
  46.                 mciSendString("play sounder notify", mci_buffer, 1024, args->hWnd);
  47.  
  48.             args->position_change = FALSE;
  49.  
  50.             PostMessage(args->hWnd, SEEK_ACK, 0, 0);
  51.             ReleaseMutex(mutex);
  52.  
  53.         } else {
  54.             ReleaseMutex(mutex);
  55.             Sleep(100);
  56.       }
  57.  
  58.       // Update the scroll bar
  59.         mciSendString("status sounder position", mci_buffer, 1024, NULL);
  60.         PostMessage(args->hWnd, SCROLL_POS, my_atoi(mci_buffer), 0);
  61.     }
  62. }
  63.  
  64.  
  65.